Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use typedefs for strings, symbols, keywords, tuples, structs, and abstracts. #1246

Merged
merged 1 commit into from
Aug 13, 2023

Conversation

wooosh
Copy link
Contributor

@wooosh wooosh commented Aug 9, 2023

This PR replaces generic const uint8_t * and Janet * types with the more specific JanetString/JanetSymbol/JanetKeyword/JanetTuple/JanetStruct/JanetAbstract.

This makes it easier for those who are new to the C API (such as myself) to figure out what these functions actually return/take as arguments. I specifically had issues understanding how the janet_getstring function worked initially because it appeared to return a pointer to the start of the string without a length.

AFAICT the only reason these functions do not use the more specific types is because their function signatures predate the typedefs existing.

I'll send a PR to update the corresponding docs at https://janet-lang.org if this gets merged.

@wooosh
Copy link
Contributor Author

wooosh commented Aug 10, 2023

They can't be made into JanetAbstract because they are const pointers. const JanetAbstract becomes the type void * const instead of the desired const void * because C's const specifier is token based. It would be nice to be able to include these, but I'm not sure how I would implement it.

@bakpakin bakpakin merged commit 6302372 into janet-lang:master Aug 13, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants